#!/usr/bin/env python
"""
Converts a token file into a lexer.
"""

## Standard Library Imports ##
import os, os.path
import logging

## 3rd-party Imports ##
from elementtree import ElementTree as ET



def main():
    logging.basicConfig(level=logging.DEBUG)
    builder = LexerBuilder(r"tokens")
    builder.return_lexers()
    return


class LexerBuilder():
    def __init__(self, directory):
        assert(os.path.isdir(directory))
        self.directory = os.path.abspath(directory)
        self._allowed_extensions = [".xml"]
        return

    def return_lexers(self):
        lexers = []
        for (dirpath, dirnames, filenames) in os.walk(self.directory):
            for name in filenames:
                name = os.path.join(dirpath, name)
                if not self._check_extension(name):
                    continue
                tree = ET.parse(name)
                
                
        return

    def _check_extension(self, filename):
        _, extension = os.pah.splittext(filename)
        return extension.lower() in self._allowed_extensions


def setup():
    tree = ET.parse(os.path.join(os.getcwd(), r"tokens\test1.xml"))
    return tree



    
